const path = require("path");
const {
  crateClassify,
  findClassifyAll,
  delClassify,
  update
} = require("../service/classify.service");

class Classify {
  async create(ctx, next) {
    try {
      await crateClassify(ctx.request.body);
      ctx.body = {
        code: 0,
        msg: "添加成功",
      };
    } catch (e) {
      console.log(e, "e");
    }
  }
  async updateClassify(ctx){
   
      await update(ctx.request.body.msg)
      ctx.body = {
          code:0,
          msg:'修改成功'
      }
  }
  async deleteClassify(ctx){

  await   delClassify(ctx.request.params.id)
      ctx.body = {
          code:0,
          msg:'删除成功'
      }
  }
  async findAll(ctx, next) {
    const res = await findClassifyAll();
    ctx.body = {
      code: 0,
      total: res.count,
      list: res.list,
    };
  }
}

module.exports = new Classify();
